/* DELETE UNNEEDED FACES*/

/*RUN THIS SCRIPT ON city_block_CURRENT.max*/

intersectionPieces = #("road292")
unhide (for obj in objects where obj.ishidden collect obj)

for roadname in intersectionPieces do
(
	execute ("selectmore $"+ roadname + "*")
)

max select invert
delete $

select $*
objList = getCurrentSelection()
for obj in $ do
(
	newFaceSel = #{} --empty bitarray
	ConvertTo obj Editable_Poly

	for f = 1 to obj.numfaces where(obj.parent == undefined) do
	(
		temp =polyop.getFaceMatID obj f		
		if temp != undefined and temp != 1 and temp != 2 and temp !=4 do
		(
			append newFaceSel f
		)
	)
	polyop.deleteFaces obj newFaceSel
)

/*OF REMAINING FACES COLOR ONES THAT ARE INTERESTING, NOTE THIS LIST of FACES WILL DIFFER FROM BEFOER SINCE WE DELETE LOTS OF FACES*/


theMat = multiMaterial numsubs:4


red_color = standard()
red_color.diffuse = color 255 0 0

blue_color = standard()
blue_color.diffuse = color 0 0 255

green_color = standard()
green_color.diffuse = color 0 255 0

horizontal_color_id = 1
vertical_color_id = 2
intersection_color_id = 3

theMat[horizontal_color_id] = red_color
theMat[vertical_color_id] = blue_color
theMat[intersection_color_id] = green_color

--intersectionPieces = #("292")
	horizontal_faces = #(
	 #{9..12, 25..27, 32}
	)
	vertical_faces = #(
	 #{1..8, 13..24, 28..31}
	)
	
	
	for obj in Geometry do
	(
		index = findItem intersectionPieces obj.name

		for f = 1 to obj.numfaces do
		(
			polyop.setFaceMatID obj f intersection_color_id
		)
		polyop.setFaceMatID obj horizontal_faces[index] horizontal_color_id
		polyop.setFaceMatID obj vertical_faces[index] vertical_color_id
		obj.material = theMat
	)
	
imageWidth = 9491
imageHeight = 5294
cameraHeight = 23586.971
	
delete $CenterCam

CenterCam = Targetcamera fov:138.915 nearclip:1 farclip:1000 nearrange:0 farrange:1000 mpassEnabled:off mpassRenderPerPass:off transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,cameraHeight]) isSelected:on target:(Targetobject transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
CenterCam.name = "CenterCam"